import java.util.*;

public class TestDay23 {
    public static void main1(String[] args) {
       int []array = {2,2,3,3,4,4};
        System.out.println(Gift.getValue(array, array.length));
    }
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        char[]array1 = scanner.nextLine().toCharArray();
        char[]array2 = scanner.nextLine().toCharArray();
        int len1 = array1.length;
        int len2 = array2.length;
        //初始化一下
        int [][]p = new int[len1+1][len2+1];
        for (int i = 0; i <= array1.length; i++) {
            p[i][0] = i;
        }
        for (int i = 0; i <= array2.length; i++) {
            p[0][i] = i;
        }
        for (int i = 1; i <= array1.length; i++) {
            for (int j = 1; j <= array2.length; j++) {
                //求出最小值+1
                //i,j表示前i个字符和前j个字符有多少区别
                p[i][j] = Math.min(p[i-1][j],p[i][j-1])+1;
                if(array1[i-1]==array2[j-1]){
                    //如果相等时
                    p[i][j] = Math.min(p[i][j],p[i-1][j-1]);
                }else {
                    //如果不相等需要加上一个修改操作
                    p[i][j] = Math.min(p[i][j],p[i-1][j-1]+1);
                }
            }
        }
        System.out.println(p[len1][len2]);
    }


}
 class Gift {
    public static int getValue1(int[] gifts, int n) {
        // write code here
        System.out.println();
        Arrays.sort(gifts);
        int p = gifts[n/2];
        int count = 0;
        for (int i = 0; i < gifts.length; i++) {
            if(gifts[i] == p){
                count++;
            }
        }
        if((count < n/2)){
           return 0;
        }

        return p;
    }
    public static int getValue(int[]gifts,int n){
        //记录
        int max = 0;//出现次数最多的值
        int count = 0;//记录出现次数
        for (int i = 0; i < n; i++) {
            if(count == 0){
                max = gifts[i];
                count++;
            }else {
                if(gifts[i] == max){
                    count++;
                }else {
                    count--;
                }
            }
        }
        count = 0;
        for (int i = 0; i < gifts.length; i++) {
            if(gifts[i] == max){
                count++;
            }
        }
        if((count < n/2)){
            return 0;
        }
       return max;



    }
}
